<?php
declare(strict_types=1);
namespace app\admin\controller;
use app\facade\Basic;
use app\admin\service\FollowRecords as ServiceFollowRecords;
use think\Request;

/**
 *  客户根据跟进记录
 */
class FollowRecords extends BaseController
{

    /**
     *   获取枚举
     */
    public function resource(Request $request)
    {
        $param['field'] = $request->param('field');
        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->getEnum($param);
        return Basic::json($result);
    }

    /**
     *  订单查询
    */
    public function getOrderList(Request $request)
    {
        $param['pageIndex'] = $request->param('pageIndex',1);
        $param['pageSize'] = $request->param('pageSize',50);
        $param['order_no'] = $request->param('order_no',null);
        $param['customer_id'] = $request->param('customer_id',null);
        $param['order_type'] = $request->param('order_type',null);

        /* 验证 */
        //$this->validateData($param,'FollowRecords.getOrderList');

        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->getOrderList($param);
        return Basic::json($result);

    }

    /**
     *  供应商/零售商
     */
    public function getList(Request $request)
    {
        $param['pageIndex'] = $request->param('pageIndex',1);
        $param['pageSize'] = $request->param('pageSize',50);
        $param['customer_id'] = $request->param('customer_id',null);
        $param['follow_method'] = $request->param('follow_method',null);
        $param['order_type'] = $request->param('order_type',null);
        $param['follow_business'] = $request->param('follow_business',null);
        $param['order_no'] = $request->param('order_no',null);

        $param['start_date'] = $request->param('start_date',null);
        $param['end_date'] = $request->param('end_date',null);

        /* 验证 */
        $this->validateData($param,'FollowRecords.getList');

        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->getList($param);
        return Basic::json($result);
    }


    /**
     *  添加
    */
    public function save(Request $request)
    {
        $param['creator'] = $request->operator_id;
        $param['customer_id'] = $request->param('customer_id',null);
        $param['follow_method'] = $request->param('follow_method',null);
        $param['follow_time'] = $request->param('follow_time',null);
        $param['follow_business'] = $request->param('follow_business',null);
        $param['order_id'] = $request->param('order_id',null);
        $param['order_type'] = $request->param('order_type',null);
        $param['follow_content'] = $request->param('follow_content',null);

        /* 验证 */
        $this->validateData($param,'FollowRecords.save');

        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->save($param);
        return Basic::json($result);
    }


    /**
     *  获取详情
    */
    public function detail(Request $request)
    {
        $param['operator_id'] = $request->operator_id;
        $param['id'] = $request->param('id',null);
        /* 验证 */
        $this->validateData($param,'FollowRecords.detail');


        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->detail($param);
        return Basic::json($result);
    }

    /**
     *  修改机型
    */
    public function update(Request $request)
    {
        $param['creator'] = $request->operator_id;
        $param['id'] = $request->param('id',null);
        $param['customer_id'] = $request->param('customer_id',null);
        $param['follow_method'] = $request->param('follow_method',null);
        $param['follow_time'] = $request->param('follow_time',null);
        $param['follow_business'] = $request->param('follow_business',null);
        $param['order_id'] = $request->param('order_id',null);
        $param['order_type'] = $request->param('order_type',null);
        $param['follow_content'] = $request->param('follow_content',null);

        /* 验证 */
        $this->validateData($param,'FollowRecords.update');

        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->update($param);
        return Basic::json($result);
   }

    /**
     *  删除机型
    */
    public function delete(Request $request)
    {
        $param['updater'] = $request->operator_id;
        $param['ids'] = $request->param('ids',null);

        /* 验证 */
        $this->validateData($param,'FollowRecords.delete');

        $serviceFollowRecords = new ServiceFollowRecords();
        $result = $serviceFollowRecords->delete($param);
        return Basic::json($result);
    }



}
